package service

import (
	"go-admin/app/alarm/models"
	"go-admin/app/alarm/service/dto"

	"github.com/go-admin-team/go-admin-core/sdk/service"

	cDto "go-admin/common/dto"
)

type SysAlarm struct {
	service.Service
}

// GetPage 获取SysAlarm列表
func (e *SysAlarm) GetPage(c *dto.SysAlarmGetPageReq, list *[]models.SysAlarm, count *int64) error {
	var err error
	var data models.SysAlarm
	err = e.Orm.Model(&data).
		Scopes(
			cDto.MakeCondition(c.GetNeedSearch()),
			cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
		).Find(list).Limit(-1).Offset(-1).
		Count(count).Error
	if err != nil {
		e.Log.Errorf("SysAlarmService GetPage error:%s \r\n", err)
		return err
	}
	return nil
}
